Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/ensure change output #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix/ensure change output #152

wants to merge 1 commit into from

Conversation

Tibo-lg
Copy link
Contributor

@Tibo-lg Tibo-lg commented Sep 21, 2023

@sosaucily I finally went with a version that handles the issue within the library. If you have time to take a look let me know.

@Tibo-lg Tibo-lg force-pushed the fix/ensure-change-output branch 3 times, most recently from 7b3d4eb to 9f6bc31 Compare March 6, 2024 06:41
dlc/Cargo.toml Show resolved Hide resolved
dlc/src/util.rs Outdated Show resolved Hide resolved
// We need to have a change output, if we didn't on first try, we request an amount which
// includes minimum value for the change output as well as the fee for it.
if total_value < appr_required_amount + min_change_value + inputs_fee + change_fee {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think the implementer of get_utxos_for_amount should ever run into this? Isn't that just a bug in their implementation of the trait method?

I see the motivation, but I think this is a bit surprising. We can work on making the API easier to use and understand, but I think we shouldn't have to fix their mistakes by trying again with a slightly bigger amount here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So your proposal is just to error if there is not enough for change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's okay, yeah. I know we have dealt with stuff like this, but I can't really blame rust-dlc if the API is clear and working as intended.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I'm still pondering on this. Wouldn't it be easier to just request an amount that includes a change output + minimum spendable amount for it from the beginning?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's reasonable too and it seems simpler than what we are currently doing. I remember thinking that it might be a good idea to give more control to consumers of this API, but I can't figure out why now.

dlc-manager/src/lib.rs Outdated Show resolved Hide resolved
dlc-manager/src/lib.rs Outdated Show resolved Hide resolved
@Tibo-lg Tibo-lg force-pushed the fix/ensure-change-output branch 2 times, most recently from 3c46ce4 to 29233b4 Compare March 14, 2024 12:03
Copy link
Collaborator

@luckysori luckysori left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sosaucily
Copy link
Contributor

Cool @Tibo-lg Can you remind me what problem this was fixing again? It's been a while since I looked at this code, but I do remember we had some trouble with it

@Tibo-lg Tibo-lg force-pushed the fix/ensure-change-output branch from 29233b4 to 97af684 Compare March 28, 2024 05:06
@Tibo-lg Tibo-lg force-pushed the fix/ensure-change-output branch from 97af684 to fe3346b Compare March 28, 2024 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants